﻿<UserControl x:Class="GeometryViz3D.Views.ModelEditor"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="Auto" Width="Auto" >
    <UserControl.Resources>
        <DataTemplate x:Key="xCellTemplate">
            <TextBox Text="{Binding X}"  Margin="-6, 0, -6, 0"/>
        </DataTemplate>
        <DataTemplate x:Key="yCellTemplate">
            <TextBox Text="{Binding Y}"  Margin="-6, 0, -6, 0" />
        </DataTemplate>
        <DataTemplate x:Key="zCellTemplate">
            <TextBox Text="{Binding Z}"  Margin="-6, 0, -6, 0"/>
        </DataTemplate>
        <DataTemplate x:Key="labelCellTemplate">
            <TextBox Text="{Binding Label}"  Margin="-6, 0, -6, 0"/>
        </DataTemplate>
        <DataTemplate x:Key="startPointCellTemplate">
            <ComboBox ItemsSource="{Binding Path=AvailablePoints}"
                      SelectedValue="{Binding StartPoint}"
                      Margin="-6, 0, -6, 0"/>
        </DataTemplate>
        <DataTemplate x:Key="endPointCellTemplate">
            <ComboBox ItemsSource="{Binding AvailablePoints}" 
                      SelectedValue="{Binding EndPoint}"
                      Margin="-6, 0, -6, 0"/>
        </DataTemplate>
        <DataTemplate x:Key="colorCellTemplate">
            <ComboBox ItemsSource="{Binding Colors}"
                      SelectedValue="{Binding Color}"
                      ItemTemplate="{StaticResource colorComboBoxItemTemplate}"
                      Margin="-6, 0, -6, 0" >
            </ComboBox>
        </DataTemplate>
    </UserControl.Resources>

    <ScrollViewer>
        <StackPanel x:Name="panel" Grid.Column="0" Orientation="Vertical"  >
            <Expander x:Name="pointExpander"  Header="Points" ExpandDirection="Down" IsExpanded="True" >
                <ListView x:Name="pointsListView" Margin="3"
                      ItemsSource="{Binding AllPoints}"  >
                    <ListView.ItemContainerStyle>
                        <Style TargetType="ListViewItem">
                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                        </Style>
                    </ListView.ItemContainerStyle>
                    <ListView.View>
                        <GridView>
                            <GridView.Columns>
                                <GridViewColumn Header="Label" 
                                            Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, 
                                                Path=ActualWidth,
                                                Converter={StaticResource doubleMultiplicationConverter},
                                                ConverterParameter=0.25}"
                                            CellTemplate="{StaticResource labelCellTemplate}" />
                                <GridViewColumn Header="X" 
                                            Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, 
                                                Path=ActualWidth,
                                                Converter={StaticResource doubleMultiplicationConverter},
                                                ConverterParameter=0.25}" 
                                            CellTemplate="{StaticResource xCellTemplate}" />
                                <GridViewColumn Header="Y" 
                                            Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, 
                                                Path=ActualWidth,
                                                Converter={StaticResource doubleMultiplicationConverter},
                                                ConverterParameter=0.25}"
                                            CellTemplate="{StaticResource yCellTemplate}" />
                                <GridViewColumn Header="Z" 
                                            Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, 
                                                Path=ActualWidth,
                                                Converter={StaticResource doubleMultiplicationConverter},
                                                ConverterParameter=0.25}"
                                            CellTemplate="{StaticResource zCellTemplate}" />
                            </GridView.Columns>
                        </GridView>
                    </ListView.View>
                </ListView>
            </Expander>
            <Expander x:Name="linesExpander" Header="Lines" ExpandDirection="Down" IsExpanded="True" >
                <ListView Margin="3" x:Name="linesListView"
                      ItemsSource="{Binding AllLines}" >
                    <ListView.ItemContainerStyle>
                        <Style TargetType="ListViewItem">
                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                        </Style>
                    </ListView.ItemContainerStyle>
                    <ListView.View>
                        <GridView>
                            <GridView.Columns>
                                <GridViewColumn Header="Point 1" 
                                            Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, 
                                                Path=ActualWidth,
                                                Converter={StaticResource doubleMultiplicationConverter},
                                                ConverterParameter=0.33}"
                                            CellTemplate="{StaticResource startPointCellTemplate}" />
                                <GridViewColumn Header="Point 2" 
                                            Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, 
                                                Path=ActualWidth,
                                                Converter={StaticResource doubleMultiplicationConverter},
                                                ConverterParameter=0.33}"
                                            CellTemplate="{StaticResource endPointCellTemplate}" />
                                <GridViewColumn Header="Color" 
                                            Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, 
                                                Path=ActualWidth,
                                                Converter={StaticResource doubleMultiplicationConverter},
                                                ConverterParameter=0.34}"
                                            CellTemplate="{StaticResource colorCellTemplate}" />
                            </GridView.Columns>
                        </GridView>
                    </ListView.View>
                </ListView>
            </Expander>
            <Expander Header="Planes">

            </Expander>
        </StackPanel>
    </ScrollViewer>
</UserControl>
